import 'package:app_03/components/MyAlertDialog.dart';
import 'package:flutter/material.dart';

main() {
  runApp(MaterialApp(home: _StatefulHome2()));
}

class _StatefulHome2 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _State2();
}

class _State2 extends State<_StatefulHome2> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text('bar'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center, // 列垂直居中对齐
            children: [
              ElevatedButton(
                  onPressed: () {
                    _showAlertDialog('发生什么事了');
                  },
                  child: Text('显示Alert弹窗')),
              ElevatedButton(
                  onPressed: () {
                    _showModalBottomDialog();
                  },
                  child: Text('显示底部弹窗'))
            ],
          ),
        ));
  }

  void _showAlertDialog(String content) {
    showDialog(
        context: context,
        builder: (_) {
          return MyAlertDialog0(content: content);
        });
  }

  void _showModalBottomDialog() {
    showModalBottomSheet(
        context: context,
        builder: (_) {
          return Container(
            child: Column(
              children: [
                Text('token: sk-123456789'),
                TextButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: Text('Copy to clipboard'))
              ],
              mainAxisAlignment: MainAxisAlignment.center,
            ),
            height: 100,
          );
        });
  }
}
